﻿using System;

namespace DBMock.Builders.Attributes
{
    /// <summary>
    /// decimal builder attribute
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class DecimalBuilderAttribute : BaseBuilderAttribute
    {
        /// <summary>
        /// decimal builder attribute constuctor
        /// </summary>
        /// <param name="min">min value</param>
        /// <param name="max">max value</param>
        public DecimalBuilderAttribute(string min = "0", string max = "79228162514264337593543950335")
            : base(typeof(DecimalBuilder))
        {
            decimal minValue;
            decimal maxValue;

            if (!decimal.TryParse(min, out minValue))
            {
                minValue = 0;
            }

            if (!decimal.TryParse(max, out maxValue))
            {
                maxValue = decimal.MaxValue;
            }

            para = new object[] { minValue, maxValue };
        }
    }
}
